package arens
{
	import base.AreaBase;
	
	import com.demonsters.debugger.MonsterDebugger;
	
	import events.EnumEvents;
	
	import feathers.controls.Button;
	import feathers.controls.Check;
	import feathers.core.FeathersControl;
	
	import flash.filesystem.File;
	
	import managers.SoundManager;
	
	import starling.core.Starling;
	import starling.display.Image;
	import starling.display.Quad;
	import starling.display.Sprite;
	import starling.display.Stage;
	import starling.events.Event;
	import starling.text.TextField;
	
	import ui.MainMenu;
	
	import utils.LoaderResource;
	
	public class Arena extends AreaBase
	{
		
		private var mainMenu:MainMenu;
		
		public function Arena(name_arena:String)
		{
			super(name_arena);
			addEventListener(Event.ADDED_TO_STAGE,addedToStage);
		}
		private function addedToStage(e:Event):void{
			removeEventListener(Event.ADDED_TO_STAGE,addedToStage);
		}
		public override function load():void{
			startLoadingArena();
		}
		
		public override function initial():void{
			trace("start initial");
			mainMenu = new MainMenu();
			addChild(mainMenu);
		}
		
		public override function clear():void{
			while(numChildren>0){
				removeChild(getChildAt(0),true);
			}
			super.clear();
			dispose();
		}
		
		
		private function startLoadingArena():void{
//			var bg:Quad = new Quad(320,480,0x0000FA);
//			addChild(bg);			
			var loader:LoaderResource = LoaderResource.instance;
			var appDir:File = File.applicationDirectory;
			loader.assetManager.enqueue(appDir.resolvePath("../bin-debug/Art/MainFon.png"),SoundManager.getInstance().getPathSound(SoundManager.BUTTON_CLICK));
			loader.assetManager.loadQueue(onCompleteLoad);
		}
		
		
	
	private function onCompleteLoad(ratio:Number):void{
		if(ratio>=1){
			var img:Image = new Image(LoaderResource.instance.assetManager.getTexture("MainFon"));
			addChild(img);
			dispatchEvent(new Event(EnumEvents.FINISH_LOAD_ARENA,true));
		}
	}
	}
}